home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Graphics⁄Sound / RTrace-1.0-src / csg.h < prev    next >
Text File  |  1992-09-17  |  2KB  |  71 lines

  1. #define RIGHT_TREE_PATH(depth) \
  2. (hit_global.data[0].tree.path[(depth) SHR 8] BIT_AND \
  3.  (1 SHL ((depth) BIT_AND 7)))
  4.  
  5. #define CSG_NODES_MAX (224)
  6.  
  7. typedef
  8. struct
  9. {
  10.   unsigned short int depth;
  11.   unsigned char   path[(CSG_NODES_MAX + 7) / 8];
  12. } tree_struct;
  13. typedef
  14. tree_struct    *tree_ptr;
  15.  
  16. #define PATH_LEFT  (0)
  17. #define PATH_RIGHT (1)
  18.  
  19. #define SAVE_TREE_PATH(side)\
  20. do {\
  21.   if ((side) == PATH_LEFT)\
  22.     tree.path[tree.depth SHR 8] &= BIT_NOT(1 SHL (tree.depth BIT_AND 7));\
  23.   if ((side) == PATH_RIGHT)\
  24.     tree.path[tree.depth SHR 8] |= 1 SHL (tree.depth BIT_AND 7);\
  25. } while (0)
  26.  
  27. typedef
  28. struct
  29. {
  30.   object_ptr      object;
  31.   real            distance;
  32.   xyz_struct      vector;
  33.   unsigned short int enter;
  34.   tree_struct     tree;
  35. } hit_node_struct;
  36.  
  37. #define ENTERING (2)
  38.  
  39. typedef
  40. struct
  41. {
  42.   short int       nodes;
  43.   hit_node_struct data[CSG_NODES_MAX];
  44. } hit_struct;
  45. typedef
  46. hit_struct     *hit_ptr;
  47.  
  48. #define CSG_SET_ENTER(hit, flag) (hit)->data[0].enter = (flag) + 1
  49.  
  50. /* Prototypes */
  51.  
  52. real
  53. #ifdef __STDC__
  54. object_intersect(object_ptr, xyz_ptr, xyz_ptr, hit_ptr, real);
  55. #else
  56. object_intersect();
  57. #endif
  58.  
  59. real csg_sec_intersect(object_ptr, xyz_ptr, xyz_ptr, hit_ptr, real);
  60.  
  61. boolean csg_intersection(xyz_ptr, xyz_ptr, hit_ptr, hit_ptr, real, real,
  62.                  hit_ptr *, real*);
  63.                  
  64. boolean csg_subtraction(xyz_ptr, xyz_ptr, hit_ptr, hit_ptr, real, real,
  65.                 hit_ptr *, real *);
  66.  
  67. boolean csg_union(xyz_ptr, xyz_ptr, hit_ptr, hit_ptr, real, real,
  68.                 hit_ptr *, real *);
  69.  
  70. void csg_copy_hit(hit_ptr, hit_ptr);
  71.